home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wsc4vb24 / atok.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-06-02  |  3.3 KB  |  121 lines

  1. VERSION 5.00
  2. Begin VB.Form ATOK 
  3.    Caption         =   "ATOK"
  4.    ClientHeight    =   2475
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   2475
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton bExit 
  13.       Caption         =   "EXIT"
  14.       Height          =   375
  15.       Left            =   360
  16.       TabIndex        =   4
  17.       Top             =   1920
  18.       Width           =   615
  19.    End
  20.    Begin VB.OptionButton oCOM2 
  21.       Caption         =   "COM2"
  22.       Height          =   375
  23.       Left            =   120
  24.       TabIndex        =   3
  25.       Top             =   480
  26.       Width           =   975
  27.    End
  28.    Begin VB.OptionButton oCOM1 
  29.       Caption         =   "COM1"
  30.       Height          =   255
  31.       Left            =   120
  32.       TabIndex        =   2
  33.       Top             =   120
  34.       Width           =   1095
  35.    End
  36.    Begin VB.TextBox eResult 
  37.       Height          =   1935
  38.       Left            =   1320
  39.       MultiLine       =   -1  'True
  40.       ScrollBars      =   2  'Vertical
  41.       TabIndex        =   1
  42.       Top             =   120
  43.       Width           =   3255
  44.    End
  45.    Begin VB.CommandButton bTest 
  46.       Caption         =   "Push to send 'AT'"
  47.       Height          =   735
  48.       Left            =   120
  49.       TabIndex        =   0
  50.       Top             =   960
  51.       Width           =   1095
  52.    End
  53. Attribute VB_Name = "ATOK"
  54. Attribute VB_GlobalNameSpace = False
  55. Attribute VB_Creatable = False
  56. Attribute VB_PredeclaredId = True
  57. Attribute VB_Exposed = False
  58. Dim wsc As New wscClass   ' instantiates wsc class
  59. Dim ThePort As Long       ' COM port
  60. Dim TestState As Integer
  61. Private Sub Sleep(ByVal MilliSec As Long)
  62. Dim Time As Long
  63. Time = SioTimer() + MilliSec
  64. While SioTimer() < Time
  65. End Sub
  66. Private Sub bExit_Click()
  67. Dim Code As Long
  68. Code = wsc.fDone(ThePort)
  69. End Sub
  70. Private Sub bTest_Click()
  71. Dim Code As Long
  72. Dim S As String
  73. Dim NL As String
  74. NL = Chr$(13) + Chr$(10)
  75. If TestState = 0 Then
  76.   ' open port
  77.   Code = wsc.fReset(ThePort, 128, 128)
  78.   If Code < 0 Then
  79.     S = GetErrorText(Code)
  80.     MsgBox S, , "fReset"
  81.     Exit Sub
  82.   End If
  83.   Code = wsc.fBaud(ThePort, 19200)
  84.   ' set DTR & RTS when talking to modem
  85.   Code = wsc.fDTR(ThePort, Asc("S"))
  86.   Code = wsc.fRTS(ThePort, Asc("S"))
  87.   ' transmit AT command (should delay between each character)
  88.   eResult.Text = eResult.Text + "Transmitting " + NL + "AT" + NL
  89.   Code = wsc.fPutc(ThePort, Asc("A"))
  90.   Call Sleep(20)
  91.   Code = wsc.fPutc(ThePort, Asc("T"))
  92.   Call Sleep(20)
  93.   Code = wsc.fPutc(ThePort, 13)
  94.   bTest.Caption = "Push to get Response"
  95.   TestState = 1
  96.   ' get response (expect "OK")
  97.   eResult.Text = eResult.Text + "Getting Response " + NL
  98.   Code = wsc.fGets(ThePort, 32)
  99.   If Code > 0 Then
  100.     S = wsc.ResultString
  101.     eResult.Text = eResult.Text + Left$(S, Code) + NL
  102.   Else
  103.     eResult.Text = eResult.Text + "No response!" + NL
  104.   End If
  105.   TestState = 0
  106.   bTest.Caption = "Push to send 'AT'"
  107.   Code = wsc.fDone(ThePort)
  108. End If
  109. End Sub
  110. Private Sub Form_Load()
  111. ThePort = COM1
  112. TestState = 0
  113. oCOM1.Value = True
  114. End Sub
  115. Private Sub oCOM1_Click()
  116. ThePort = COM1
  117. End Sub
  118. Private Sub oCOM2_Click()
  119. ThePort = COM2
  120. End Sub
  121.